#include <iostream>
#include <memory>
#include <functional>
#include "Reactor.hpp"
#include "Connection.hpp"
#include "Log.hpp"
#include "Listener.hpp"
int main(int argc,char* argv[])
{
    if(argc != 2)
    {
        std::cout << "Usage:" << argv[0] << " port" << std::endl;
        return 0;
    }
    EnableScreen();
    std::unique_ptr<Reactor> svr = std::make_unique<Reactor>();

    uint16_t port = std::stoi(argv[1]);

    Listener listen(port);
    svr->AddConnection(listen.Sockfd(),
    EPOLLIN|EPOLLET,
    std::bind(&Listener::Accepter, &listen, std::placeholders::_1),
    nullptr,
    nullptr);
    svr->Dispatcher();
    return 0;
}